# 创建集合set，set（）用来创建集合的函数，type用来表示查看数据类型
# s = {1, 2, 3, 4}
# ss = set("1234")
# print(type(s))
# print(type(ss))
# s.add(6)
# print(s)
# s.pop()
# print(s)
# s.remove(2)
# print(s)
# tuple1 = ()
# print(tuple)
#
# tuple2 = (1, "a", 3, "hi", 6.6)
# print(tuple2)
#
# tuple3 = (1,)
# print(type(tuple3))
#
# tuple1 = tuple("hello,world")
# print(tuple1)
#
# list1 = ["python","java","c++","c"]
# tuple2 = tuple(list1)
# print(tuple2)
# 索引
# tuple1 = ("h", "e", "l", "l", "o")
# print(tuple[2])
# print(tuple[-4])
# # 使用正数切片
# print(tuple1[1:4])
# # 指定步长
# print(tuple1[1:4:2])
# # 使用负数切片
# print(tuple1[-5:-1])
\ No newline at end of file
# tuple1 = (12, 34, 56)
# tuple2 = ("abc", "mn")
# # 不可以修改元组可以添加
# tuple3 = tuple1 + tuple2
# print(tuple3)
# del(tuple1)
# n=input("姓名")
# t=input("手机号")
# e=input("邮件")
# a=input("地址")
# tuple4 = ("姓名:", n, "手机号:", t, "邮件:", e, "地址", a)
# print(tuple4)
# 列表的创建
# list1 = [1, "hello", 2, "c语言"]
# print(list1)
# print(type(list1))
# # 空列表
# list2 = []
# print(list2)
# # 转化字符串
# l3 = list("hello")
# print(l3)
# # 转化元组
# t1 = tuple("hello")
# l4 = list(t1)
# print(l4)
# # 转化range函数
# r1 = range(5)#0,1,2,3,4
# print(r1)
# l5 = list(r1)
# print(l5)
# 访问列表元素
# l1 = [1, 2, 3, 4, 5, 6, "p", "i"]
# # 正索引访问p
# print(l1[6])
# # 负索引访问p
# print(l1[-2])
# # 切片访问
# l2 = ["p", 'y', "t", "h", "o", "n"]
# # 正切片截取234的元素
# print(l2[2:5])
# # 截取0到2的元素
# print(l2[:3])
# # 截取3-5
# print(l2[3:])
# # 正切片截取1-5 步长为2
# print(l2[1:6:2])
# # 负切片
# print(l2[-5:-1])
# # 步长是负数从右到左
# print(l2[::-1])
# # 用切片访问列表元素
# l3 = ["z", "x", "c", "v", 1, 2, 3]
# # 正向取值
# # 正切片取索引234
# print(l3[2:5])
# # 正切片取前三
# print(l3[:3])
# # 正切片取后三
# print(l3[4:])
# # 正切片取1-5 步长2
# print(l3[1:6:2])
# # 负向取值
# # 取出x c v
# print(l3[-6:-3])
# # 步长为负数取值从右到左
# print(l3[::-1])
# l4 = [1, 2, 3, 4, 5, 6]
# print(l4[::-1])
# # 遍历循环
# # 用for循环
# l4 = ['1', '2', '3', '4']
# for i in l4:
#     print(i)
# # 修改列表元素
# # 修改单个元素
# l4[2] = 1000
# print(l4)
# # 修改多个元素
# l5 = [1, 2, 3, 4, 5, 6]
# # 修改1-4不包含四
# l5[1:4] = [12, -33, 1000]
# print(l5)
# # 添加元素
# l6 = ['a', 'b', 'c']
# l6.append('f')
# print(l6)
# # 列表添加列表
# l6.append(['e', 'f'])
# print(l6)
#
# # 在末尾添加
# l7 = ['a', 'b', 'c']
# l7.extend('d')
# print(l7)
# # 列表添加列表
# l7.extend(['e','f','g','h'])
# print(l7)
# l7.extend('world')
# print(l7)
# # 添加特定
# l8 = ['p','c','j']
# # 插入c++
# l8.insert(2,'c++')
# print(l6)
# 删除元素
# l9 = ['a', 'b', 'g', 'y']
# l9.remove('a')
# print(l9)
# 如果列表没有元素删除会报错
# l9.remove('l')
# pop删除索引元素
l10 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# 删除索引4
l10.pop(4)
print(l10)
# 不索引删除最后一个
l10.pop()
print(l10)
# del#del可以用来删除列表中单个元素或者一段连续的元素
L11 = ['a', 'b', 'c', 'd', 'e']
# 删除索引为1的元素
del L11[1]
print(L11)
l11 = [10, 56, 34, 2, 58, 44, 7]
# 删除索引为1-3的元素
del l11[1:4]
print(l11)
# 若将列表中所有元素全部删除，可使用列表的clear()方法
l12 = ['1', '2', '3', '4']
# 清空
l12.clear()
print(l12)
# 任务
n_list = []
p_list = []
while 1:
    print('菜单：1.添加联系人 2.修改联系人 3.删除联系人')
    a = input('请输入选择:')
    #     添加联系人
    if a == '1':
        n_list.append(input('请输入联系人姓名：'))
        p_list.append(input('请输入联系人手机号：'))
        print(n_list)
        print(p_list)
        # 修改联系人信息
    elif a == "2":
        num = int(input('请输入联系人编号：'))
        if len(n_list) > 0 and num <= len(n_list):
            n_list[num - 1] = input('修改联系人姓名')
            p_list[num - 1] = input('修改联系电话')
        else:
            print('输入有误')
    # 删除信息
    elif chioce == "3":
        num = int(input("请输入联系人编号："))
        if len(name_list) > 0 and num <= len(name_list):
            name_list.pop(num - 1)
            phone_list.pop(num - 1)
        else:
            print("联系人编号输入有误")
    else:
        print("显示联系人信息")
        print(name_list)
        print(phone_list)
l1 = [1, 3, 4, 7, 'c', 'd', '6', 2, 'c', 0]
print(l1.index(3))
print(l1.index('c', 6))
print(l1.index('c', 6, 9))
# count()统计出现次数
l2 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 23, 4, 5, 6, 7, 5, 5, 5, 7, 7, 7, 8, 8, 8]
print(l2.count(5))
print(l2.count(7))
print(l2.count(2))
# 元素排序 sort（）用于排序
# 字符串排序
l3 = ['1', '3', '5', '45', '55', '66']
# 默认升序
l3.sort()
print(l3)
# 降序 True
l3.sort(reverse=True)
print(l3)
# 元素是数值的排序
l4 = [1, 2, 34, 6, 7, 44, 55, 666, 888]
l4.sort()
print(l4)
l4.sort(reverse=True)
print(l4)
# 字典的创建
# 1使用{}创建字典语法格式
# 字典名={‘key’：‘value’}
# 使用字符串作为key
d1 = {'python': 90, '可视化': 99, '英语':100}
print(type(d1))
# 使用元组和数字作为key
d2 = {[24, 99]: "great", 10:[1, 2, 3]}
print(type(d2))
# 创建空元组
d3 = {}
print(d3)
# 2用dict（）
d4 = {'数学': 99, '语文': 99, '英语': 99}
print(d4)
# 字典元素访问
# 1字典名[key]
# d1 = {'数学':95,'英语':100,'语文':99}
# # 键存在返回值是value
# print(d1['英语'])
# # 键不存在会引发错误
# print(d1['1'])
# # 2 用get来获取
# d2 = {'数学':95,'英语':100,'语文':99}
# # 存在
# print(d2.get('语文'))
# # 存在不写default会none
# print(d2.get('1'))
# print(d2.get('1', '不存在'))
# 字典添加
# d3 = {'数学':95,'英语':100,'语文':99}
# d3['可视化'] = 99
# print(d3)
# # 字典修改键值对
# d4 = {'数学':95,'英语':100,'语文':99}
# d4['数学'] = 100
# print(d4)
# # 删除键值对
# d5 = {'数学':95,'英语':100,'语文':99}
# # 1使用del关键字
# del d5['语文']
# print(d5)
# # 2使用pop
# d5.pop('英语')
# print(d5)